<?php
	
	$db = new mysql_db($config->get('dbhost'), $config->get('dbuser'),  $config->get('dbpass'), $config->get('dbname'), false);
		
	add_database($db, $db_name);

	// CLASES MODELO DE NEGOCIO	
	class UsuarioRol extends BusinessObject
	{
		function UsuarioRol()
		{
			$this->table_name = "si_usuario_rol";
			$this->field_metadata = array(
					"id" => array("int"),
					"id_usuario" => array("varchar"),
					"id_rol" => array("int")					
				);
			parent::BusinessObject();
		}
	}

	class UsuarioRolCollection extends BusinessObjectCollection
	{
		function UsuarioRolCollection()
		{
			parent::BusinessObjectCollection();
		}
		
		function create_singular($row) 
		{ 
			$obj = new UsuarioRol();
			$obj->load_from_list($row);
			
			return $obj;
		}
	}
	
	class Rol extends BusinessObject
	{
		function Rol()
		{
			$this->table_name = "si_rol";
			$this->field_metadata = array(
					"id" => array("int"),
					"descripcion" => array("varchar")
					
				);
			parent::BusinessObject();
		}
	}

	class RolCollection extends BusinessObjectCollection
	{
		function RolCollection()
		{
			parent::BusinessObjectCollection();
		}
		
		function create_singular($row) 
		{ 
			$obj = new Rol();
			$obj->load_from_list($row);
			
			return $obj;
		}
	}
	
	class Seccion extends BusinessObject
	{
		function Seccion()
		{
			$this->table_name = "si_seccion_layout";
			$this->field_metadata = array(
					"id" => array("int"),
					"descripcion" => array("varchar"),
					"id_layout" => array("int"),
					"coordx" => array("int"),
					"coordy" => array("int"),
					"imagen" => array("varchar"),
					"estado" => array("char")
					
				);
			parent::BusinessObject();
		}
	}

	class SeccionCollection extends BusinessObjectCollection
	{
		function SeccionCollection()
		{
			parent::BusinessObjectCollection();
		}
		
		function create_singular($row) 
		{ 
			$obj = new Seccion();
			$obj->load_from_list($row);
			
			return $obj;
		}
	}
	
	class Layout extends BusinessObject
	{
		function Layout()
		{
			$this->table_name = "si_layout";
			$this->field_metadata = array(
					"id" => array("int"),
					"descripcion" => array("varchar"),
					"imagen" => array("varchar"),
					"estado" => array("char")
					
				);
			parent::BusinessObject();
		}
	}

	class LayoutCollection extends BusinessObjectCollection
	{
		function LayoutCollection()
		{
			parent::BusinessObjectCollection();
		}
		
		function create_singular($row) 
		{ 
			$obj = new Layout();
			$obj->load_from_list($row);
			
			return $obj;
		}
	}
	
	class Usuario_layout extends BusinessObject
	{
		function Usuario_layout()
		{
			$this->table_name = "si_usuario_layout";
			$this->field_metadata = array(
					"id_usuario" => array("varchar"),
					"id_dispositivo" => array("int")
				);
			parent::BusinessObject();
		}
	}

	class Usuario_layoutCollection extends BusinessObjectCollection
	{
		function Usuario_layoutCollection()
		{
			parent::BusinessObjectCollection();
		}
		
		function create_singular($row) 
		{ 
			$obj = new Usuario_layout();
			$obj->load_from_list($row);
			
			return $obj;
		}
	}
	
	class ConfiguracionDispositivo extends BusinessObject
	{
		function ConfiguracionDispositivo()
		{
			$this->table_name = "si_configuracion_dispositivo";
			$this->field_metadata = array(
					"id" => array("int"),
					"id_dispositivo" => array("int"),
					"ubicacion" => array("varchar"),
					"posicion_relativa" => array("varchar"),
					"altura" => array("varchar"),
					"id_tipo_alerta" => array("int"),
					"id_modo_camara" => array("int"),
					"sensibilidad" => array("int"),
					"estado" => array("char")
				);
			parent::BusinessObject();
		}
	}

	class ConfiguracionDispositivoCollection extends BusinessObjectCollection
	{
		function ConfiguracionDispositivoCollection()
		{
			parent::BusinessObjectCollection();
		}
		
		function create_singular($row) 
		{ 
			$obj = new ConfiguracionDispositivo();
			$obj->load_from_list($row);
			
			return $obj;
		}
	}
	
	class ModoCamara extends BusinessObject
	{
		function ModoCamara()
		{
			$this->table_name = "si_modo_camara";
			$this->field_metadata = array(
					"id" => array("int"),
					"descricion" => array("varchar"),
					"estado" => array("char")
				);
			parent::BusinessObject();
		}
	}

	class ModoCamaraCollection extends BusinessObjectCollection
	{
		function ModoCamaraCollection()
		{
			parent::BusinessObjectCollection();
		}
		
		function create_singular($row) 
		{ 
			$obj = new ModoCamara();
			$obj->load_from_list($row);
			
			return $obj;
		}
	}
	
	class TipoAlerta extends BusinessObject
	{
		function TipoAlerta()
		{
			$this->table_name = "si_tipo_alertas";
			$this->field_metadata = array(
					"id" => array("int"),
					"descricion" => array("varchar"),
					"estado" => array("char")
				);
			parent::BusinessObject();
		}
	}

	class TipoAlertaCollection extends BusinessObjectCollection
	{
		function TipoAlertaCollection()
		{
			parent::BusinessObjectCollection();
		}
		
		function create_singular($row) 
		{ 
			$obj = new TipoAlerta();
			$obj->load_from_list($row);
			
			return $obj;
		}
	}
	
	class Dispositivo extends BusinessObject
	{
		function Dispositivo()
		{
			$this->table_name = "si_dispositivo";
			$this->field_metadata = array(
					"id" => array("int"),
					"descripcion" => array("varchar"),
					"direccion_ip"=> array("varchar"),
					"nro_serie" => array("varchar"),
					"modelo" => array("varchar"),
					"marca" => array("varchar"),
					"id_tipo_dispositivo" => array("int"),
					"id_estado_dispositivo" => array("int"),
					"estado" => array("char")

				);
			parent::BusinessObject();
		}
	}

	class DispositivoCollection extends BusinessObjectCollection
	{
		function DispositivoCollection()
		{
			parent::BusinessObjectCollection();
		}
		
		function create_singular($row) 
		{ 
			$obj = new Dispositivo();
			$obj->load_from_list($row);
			
			return $obj;
		}
	}
	
	class Panel_control extends BusinessObject
	{
		function Panel_control()
		{
			$this->table_name = "si_panel_control";
			$this->field_metadata = array(
					"id" => array("int"),
					"ventana" => array("varchar"),
					"cuadrante" => array("varchar"),
					"contenido" => array("varchar"),
					"tipo_carga" => array("varchar"),
					"usuario" => array("varchar")

				);
			parent::BusinessObject();
		}
	}

	class Panel_controlCollection extends BusinessObjectCollection
	{
		function Panel_controlCollection()
		{
			parent::BusinessObjectCollection();
		}
		
		function create_singular($row) 
		{ 
			$obj = new Panel_control();
			$obj->load_from_list($row);
			
			return $obj;
		}
	}
	
	class TipoDispositivo extends BusinessObject
	{
		function TipoDispositivo()
		{
			$this->table_name = "si_tipo_dispositivo";
			$this->field_metadata = array(
					"id" => array("int"),
					"descricion" => array("varchar"),
					"estado" => array("char")
				);
			parent::BusinessObject();
		}
	}

	class TipoDispositivoCollection extends BusinessObjectCollection
	{
		function TipoDispositivoCollection()
		{
			parent::BusinessObjectCollection();
		}
		
		function create_singular($row) 
		{ 
			$obj = new TipoDispositivo();
			$obj->load_from_list($row);
			
			return $obj;
		}
	}
	
	class EstadoDispositivo extends BusinessObject
	{
		function EstadoDispositivo()
		{
			$this->table_name = "si_estado_dispositivo";
			$this->field_metadata = array(
					"id" => array("int"),
					"descricion" => array("varchar"),
					"estado" => array("char")
				);
			parent::BusinessObject();
		}
	}

	class EstadoDispositivoCollection extends BusinessObjectCollection
	{
		function EstadoDispositivoCollection ()
		{
			parent::BusinessObjectCollection();
		}
		
		function create_singular($row) 
		{ 
			$obj = new EstadoDispositivo();
			$obj->load_from_list($row);
			
			return $obj;
		}
	}
	
		
	// CLASES DESOPORTE SISTEMA
	class respaldo extends BusinessObject
	{
		function respaldo()
		{
			$this->table_name = "si_respaldo";
			$this->field_metadata = array(
					"id" => array("int"),
					"fecha" => array("date"),
					"activo" => array("char")
				);
			parent::BusinessObject();
		}
	}
	
	class Usuarios extends BusinessObject
	{
		function Usuarios()
		{
			$this->table_name = "si_usuarios";
			$this->field_metadata = array(
					"id" => array("int"),
					"id_usuario" => array("varchar"),
					"clave" => array("varchar"),
					"nom_usuario" => array("varchar"),
					"ape_usuario" => array("varchar"),
					"activo" => array("char"),
					"fec_alta" => array("datetime"),
				);
			parent::BusinessObject();
		}
	}

	class UsuariosCollection extends BusinessObjectCollection
	{
		function UsuariosCollection()
		{
			parent::BusinessObjectCollection();
		}
		
		function create_singular($row) 
		{ 
			$obj = new Usuarios();
			$obj->load_from_list($row);
			
			return $obj;
		}
	}
	
	// CLASES SOPORTE SQL 
	class SqlPersonalizado extends SqlSoporte
	{
		function SqlPersonalizado($h, $u, $p)
		{
			parent::SqlSoporte($h, $u, $p);
		}
	}
	
	
	
	
?>